package com.net.mindview.util;

import java.util.ArrayList;
import java.util.Random;

public class Store extends ArrayList<Aisle>{
	private ArrayList<CheckoutStand> checkouts=new ArrayList<CheckoutStand>();
	private Office office=new Office();
	public Store(int nAisle,int nShelves,int nProducts){
		for(int i=0;i<nAisle;i++){
			add(new Aisle(nShelves, nProducts));
		}
	}
	public String toString(){
		StringBuilder result=new StringBuilder();
		for(Aisle a:this){
			for(Shelf s:a){
				for(Product p:s){
					result.append(p);
					result.append("\n");
				}
			}
		}
		return result.toString();
	}
	public static void main(String[] args) {
		System.out.println(new Store(14, 5, 10));
	}
}
class CheckoutStand{}
class Office{}
class Aisle extends ArrayList<Shelf>{
	public Aisle(int nShelf,int nProducts){
		for(int i=0;i<nShelf;i++){
			add(new Shelf(nProducts));
		}
	}
}
class Shelf extends ArrayList<Product>{
	public Shelf(int nProducts){
		Generators.fill(this, Product.generator, nProducts);
	}
}
class Product{
	private final int id;
	private String description;
	private double price;

	public Product(int IDnumber, String desc, double price) {
		this.id = IDnumber;
		this.description = desc;
		this.price = price;
	}

	public String toString() {
		return id + ": " + description + ", price:$" + price;
	}

	public void priceChange(double change) {
		price += change;
	}

	public static Generator<Product> generator = new Generator<Product>() {
		private Random rand = new Random(47);

		public Product next() {
			// TODO Auto-generated method stub
			return new Product(rand.nextInt(1000), "Test", Math.round(rand
					.nextDouble() * 1000.0) + 0.99);
		}
	};
}